package com.zhz.lib.cms.security.userinfo;

import java.util.Map;

import org.springframework.dao.DataAccessException;
import org.springframework.security.userdetails.UserDetails;
import org.springframework.security.userdetails.UserDetailsService;
import org.springframework.security.userdetails.UsernameNotFoundException;

public class UserInfoService implements UserDetailsService {
	private Map<String, UserInfo> userMap = null;
	private UserInfoBuilder userInfoBuilder;

	public UserDetails loadUserByUsername(String username)
			throws UsernameNotFoundException, DataAccessException {
		userMap = userInfoBuilder.buildUserInfoMap(username);
		return userMap.get(username);
	}

	public void setUserInfoBuilder(UserInfoBuilder userInfoBuilder) {
		this.userInfoBuilder = userInfoBuilder;
	}

}
